package com.bot.rf.excel;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.*;
import com.bot.rf.entity.BookInfo;
import org.apache.poi.ss.usermodel.HorizontalAlignment;

/**
 * @program: report-form-demo
 * @description: 异常图书Excel模板
 * @author: zyy
 * @create: 2021-02-25 14:39
 **/

@ContentRowHeight(18)
@HeadRowHeight(18)
@HeadFontStyle(fontHeightInPoints = 11, fontName = "等线")
@HeadStyle(horizontalAlignment = HorizontalAlignment.LEFT)
public class AbnormalExcel implements Comparable{


    /**
     * tagId
     */
    @ColumnWidth(30)
    @ExcelProperty("tagId")
    private String tagId;

    /**
     * 条形码
     */
    @ColumnWidth(20)
    @ExcelProperty("条形码")
    private String barcode;

    /**
     * 楼层
     */
    @ColumnWidth(10)
    @ExcelProperty("楼层")
    private String floor;

    /**
     * 盘点层架标
     */
    @ColumnWidth(30)
    @ExcelProperty("盘点层架标")
    private String shelf;

    /**
     * 层架标代码
     */
    @ColumnWidth(20)
    @ExcelProperty("层架标代码")
    private String shelfCode;


    public String getTagId() {
        return tagId;
    }

    public void setTagId(String tagId) {
        this.tagId = tagId;
    }

    public String getBarcode() {
        return barcode;
    }

    public void setBarcode(String barcode) {
        this.barcode = barcode;
    }

    public String getFloor() {
        return floor;
    }

    public void setFloor(String floor) {
        this.floor = floor;
    }

    public String getShelf() {
        return shelf;
    }

    public void setShelf(String shelf) {
        this.shelf = shelf;
    }


    public String getShelfCode() {
        return shelfCode;
    }

    public void setShelfCode(String shelfCode) {
        this.shelfCode = shelfCode;
    }

    public AbnormalExcel(BookInfo bookInfo, String floor,String shelf,String shelfCode) {
        this.barcode = bookInfo.getBarcode();
        this.tagId = bookInfo.getTagId();
        this.floor = floor;
        this.shelf = shelf;
        this.shelfCode = shelfCode;
    }

    @Override
    public String toString() {
        return "ExportBookExcel{" +
                "barcode='" + barcode + '\'' +
                ", floor='" + floor + '\'' +
                ", shelf='" + shelf + '\'' +
                ", tagId='" + tagId + '\'' +
                '}';
    }

    /**
     * 重写比较逻辑
     * 楼层 > 层架标 > 序号
     * @param o
     * @return
     */
    @Override
    public int compareTo(Object o) {
        AbnormalExcel tagModel = (AbnormalExcel) o;
        int res;
        if (floor.equals(tagModel.floor)) {
            if (shelf.equals(tagModel.shelf)) {
                res = 0;
            } else {
                res = shelf.compareTo(tagModel.shelf);
            }
        } else {
            res = floor.compareTo(tagModel.floor);
        }
        return res;
    }
}
